package br.com.saab.quantotempofalta.menu.item;

import java.awt.MenuItem;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * MenuItem que fecha o sistema
 * 
 * @author Felipe
 */
@Component
public class SairMenu extends MenuItem {
	
	private static final long serialVersionUID = 446306867490261136L;

	@Autowired
	public SairMenu(final SystemTray tray, final TrayIcon trayIcon) {
		super("Sair");
		
		addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                tray.remove(trayIcon);
                System.exit(0);
            }
        });
	}
	
}
